package com.xy.example1;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author 谢阳
 * @version 1.8.0_131
 * @date 2022/6/14 9:45
 * @description
 */
public class WebSiteFactory {
    private static final WebSiteFactory instance = new WebSiteFactory();

    private WebSiteFactory(){
    }

    public static WebSiteFactory getInstance() {
        return instance;
    }

    private HashMap<String,WebSite> pool = new HashMap<>();

    // 根据网站类型返回发布网站
    public WebSite getWebSite(String type) {
        if (!pool.containsKey(type)) {
            pool.put(type,new ConcreteWebSite(type));
        }
        return pool.get(type);
    }

    // 获取网站分类总数
    public int getWebSiteCount() {
        return pool.size();
    }


}
